package demo1;


public class Test {
    public static void main(String[] args) {
        Animal animal = new Dog(2,"大狗");
        if(animal instanceof Dog){
            Dog dog = (Dog) animal;
            dog.bark();
            System.out.println("animal是引用了dog这个对象");
        }else{
            System.out.println("animal不是引用了dog这个对象");
        }
        if(animal instanceof Brid){
            Brid brid = (Brid) animal;
            brid.fly();
            System.out.println("animal 是引用了brid这个类型");
        }else{
            System.out.println("animal 不是引用了brid这个类型");
        }
    }
    public static void main2(String[] args) {
        Animal animal1 = new Dog(2,"小狗");
        Dog dog = (Dog) animal1;
        dog.bark();
    }


    public static void main1(String[] args) {

        Dog dog1 = new Dog(3, "旺财");
        Brid brid1 = new Brid(1,"小鸟");
        //dog1.eat();
        Animal animal1 = new Dog(5,"小丑");
        //animal1.eat();
        //animal1.bark();
        func(dog1);
        func(brid1);

    }
    public static void func(Animal animal2){
        animal2.eat();
    }
}
